﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using BaseData;
using BaseData.Common;
using BaseData.UI;

namespace TaxData.User
{
    /// <summary>
    /// 用户权限管理
    /// </summary>
    public class PowerInfoData
    {
        /// <summary>
        /// 获取用户权限详细列表
        /// </summary>
        /// <param name="powerIDs">权限ID列表</param>
        /// <returns>权限详细列表</returns>
        public static DataTable GetPowerInfo(int userPowerType)
        {
            string powerIDs = GetPowerIDs(userPowerType);
            string sql = "select * from PowerInfo where powerID in (" + powerIDs + ") order by sort";
            //string sql = "select * from PowerInfo  order by sort";
            DataTable dt = DataConfig.QueryRecords(BusinessType.DBRead, sql);
            return dt;
        }

        /// <summary>
        /// 根据用户级别获取权限ID列表
        /// </summary>
        public static string GetPowerIDs(int userPowerType)
        {
            string sql = "select powerid from userpower where usertype=" + userPowerType;
            string powerIDs = DataConfig.GetSingle(BusinessType.DBRead, sql).ToString();
            return powerIDs;
        }

        /// <summary>
        /// 获取岗位列表
        /// </summary>
        public static DataTable GetGangweiList()
        {
            string sql = "select * from UserPower with(nolock) where status=1 order by typeName";
            DataTable dt = DataConfig.QueryRecords(BusinessType.DBRead, sql);
            return dt;
        }

    }
}
